import axios from '@/utils/request'
export default {
  ProfitRule: {
    form: {
      fields: [
        'store',
        'name',
        'enabled',
        { property: 'priority', help: '同一个产品提成方案，只会执行一个，按照优先级从小到大执行' },
        { property: 'validator', type: 'code' }
      ]
    },
    list: {
      list_filter: {
        'store.id': () => {
          return axios
            .get(`/manage/stores`)
            .then(res =>
              Object.assign({ __label: '门店' },
                ...res.data.map(v => { return { [v.id]: v.name } })))
        }
      },
      list_display: [
        'id',
        'store',
        'name',
        'enabled',
        { property: 'priority', label: '优先级' }
      ]
    }
  }
}
